package com.macro.mall.portal.service.impl;

import com.macro.mall.domain.PmsAlbumPicResult;
import com.macro.mall.domain.UploadResult;
import com.macro.mall.mapper.SmsHomeAdvertiseMapper;
import com.macro.mall.model.SmsHomeAdvertise;
import com.macro.mall.model.SmsHomeAdvertiseExample;
import com.macro.mall.portal.root.upload.UploadFileService;
import com.macro.mall.portal.service.SmsHomeAdvertiseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartHttpServletRequest;

import java.io.File;
import java.util.List;

@Service
public class SmsHomeAdvertiseServiceImpl extends UploadFileService implements SmsHomeAdvertiseService {
    //    @Override
//    public UploadResult uploadFile(MultipartHttpServletRequest multiRequest) throws Exception {
//        return null;
//    }
    @Autowired
    private SmsHomeAdvertiseMapper smsHomeAdvertiseMapper;

    @Override
    public PmsAlbumPicResult saveMassage(File file) {
        SmsHomeAdvertise smsHomeAdvertise = new SmsHomeAdvertise();
        smsHomeAdvertise.setId(null);
        smsHomeAdvertise.setPic(file.getPath());
        smsHomeAdvertise.setStatus(1);
        smsHomeAdvertiseMapper.insert(smsHomeAdvertise);
        return null;
    }

    @Override
    public List<SmsHomeAdvertise> getAdvertise() {
        SmsHomeAdvertiseExample smsHomeAdvertiseExample = new SmsHomeAdvertiseExample();
        SmsHomeAdvertiseExample.Criteria criteria = smsHomeAdvertiseExample.createCriteria();
        criteria.andStatusEqualTo(1);
        return smsHomeAdvertiseMapper.selectByExample(smsHomeAdvertiseExample);
    }
}
